package com.potenza.training.reply.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.potenza.training.reply.entity.ReplySubjectRecordEntity;
import com.potenza.training.reply.service.ReplySubjectRecordService;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Map;



/**
 * 每次答辩记录得题目
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-07-22 15:57:42
 */
@RestController
@RequestMapping("reply/replysubjectrecord")
public class ReplySubjectRecordController {
    @Autowired
    private ReplySubjectRecordService replySubjectRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list/{page}/{size}")
    public R list(@RequestBody Map<String,Object> params, @PathVariable Integer page, @PathVariable Integer size){
        Page<ReplySubjectRecordEntity> pageData = replySubjectRecordService.queryPage(params,page,size);

        return R.ok().put("page", pageData);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("reply:replysubjectrecord:info")
    public R info(@PathVariable("id") Long id){
		ReplySubjectRecordEntity replySubjectRecord = replySubjectRecordService.getById(id);

        return R.ok().put("replySubjectRecord", replySubjectRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("reply:replysubjectrecord:save")
    public R save(@RequestBody ReplySubjectRecordEntity replySubjectRecord){
		replySubjectRecordService.save(replySubjectRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("reply:replysubjectrecord:update")
    public R update(@RequestBody ReplySubjectRecordEntity replySubjectRecord){
		replySubjectRecordService.updateById(replySubjectRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("reply:replysubjectrecord:delete")
    public R delete(@RequestBody Long[] ids){
		replySubjectRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
